<?php

namespace app\admin\controller;

use think\Controller;
use app\api\controller\User;

class BaseController extends Controller
{

    protected  $user;   //存储登陆用户信息
    public function initialize(){
        parent::initialize();
        $this->isLogin();
        $this->assign('user',$this->user);
    }

    private function isLogin(){
        if($userInfo = User::checkLogin()){
            $this->user = $userInfo;
        }else{
            $this->redirect(url('/admin/login'));
        }
    }
}
